import java.util.Random;
import java.util.Scanner;

public class Text {
    public static void main(String[] args) {
        System.out.println();
    }
    public static void main6(String[] args) {
        int count = 0;
        for(int i = 0;i <= 100;i++) {
            if(i/10 == 9 || i%10 == 9) {
                count++;
            }
        }
        System.out.println(count);
    }
    public static void main5(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()) {
            System.out.println(scanner.next());
        }
    }



















    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        while(a % b != 0) {
            int c = a % b;
            a = b;
            b = c;
        }
        System.out.println(b);
    }
    public static void main3(String[] args) {
        int i = 0;
        while(i < 100) {
            i++;
            if(i % 3 != 0 || i % 5 != 0) {
                continue;
            }
                System.out.print(i + " ");
        }
    }
    public static void main2(String[] args) {
        Random random = new Random();
        random.nextInt();
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        for(int i = 0; i<= 5;i++) {
            for(int j = 0;j <=5 ;j++) {
                if(i == 1) {
                    break;
                }
                System.out.print("i=  " + i);
                System.out.print("j= " + j);
            }
            System.out.println();
        }
    }
    public static void main1(String[] args) {
        int i = 1;
        int sum1 = 0;
        int sum2 = 0;
        while(i <= 100) {
            if(i % 2 == 0) {
                sum1 += i;
            }else {
                sum2 += i;
            }
            i++;
        }
        System.out.println("奇数和：" + sum2 + " " + "偶数和" + sum1 + " ");
    }

    /**
     *129. 求根节点到叶节点数字之和
     * https://leetcode.cn/problems/sum-root-to-leaf-numbers/description/?envType=study-plan-v2&envId=top-interview-150
     */
    //具有返回值的dfs方法
    class Solution1 {
        public int sumNumbers(TreeNode root) {
            return sum1(root,0);
        }
        public int sum1(TreeNode root , int sum) {
            if(root == null) {
                return 0;
            }
            //确保root ！= null
            //sum = sum += root.val
            sum = sum * 10 + root.val;
            if(root.left == null && root.right == null) {
                return sum;
            }else {
                return sum1(root.left,sum) + sum1(root.right , sum);
            }
        }
    }

    //无需返回值的dfs方法
    // 只关心在叶子结点处的累加，#1，#2，#3的位置是任意的，即前序中序后序都可以
    class Solution {
        int sum = 0;
        public int sumNumbers(TreeNode root) {
            dfs(root,0);
            return sum;
        }
        public void dfs(TreeNode node , int num) {
            if(node == null) {
                return;
            }
            num = num * 10 + node.val;
            if(node.left == null && node.right == null) {
                sum += num;
            }else {
                dfs(node.left,num);
                dfs(node.right,num);
            }
        }
    }


}
